package amit.ui.table;

import amit.ad.AdDetails;
import ca.odell.glazedlists.gui.*;

/**
 * 
 * @author ido
 * 
 */
public class AdTableFormat implements TableFormat {

	public int getColumnCount() {
		return 6;
	}

	/**
	 * String type, float rooms, int price, String address, String city, String
	 * comments) {
	 */
	public String getColumnName(int column) {
		if (column == 0)
			return "Type";
		else if (column == 1)
			return "Rooms";
		else if (column == 2)
			return "Price";
		else if (column == 3)
			return "Address";
		else if (column == 4)
			return "City";
		else if (column == 5)
			return "Comments";
		throw new IllegalStateException();
	}

	/**
	 * 
	 */
	public Object getColumnValue(Object baseObject, int column) {
		AdDetails ad = (AdDetails) baseObject;

		if (column == 0)
			return ad.getType();
		else if (column == 1)
			return ad.getRooms();
		else if (column == 2)
			return ad.getPrice();
		else if (column == 3)
			return ad.getAddress();
		else if (column == 4)
			return ad.getCity();
		else if (column == 5)
			return ad.getComments();

		throw new IllegalStateException();
	}

}